Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

262
Views
WebSocket connection to "wss://my_amazon_ec2_machine" failed

I have updated my website by making the domain name point to cloudflare servers, then, have cloudflare point to my webhost. Before changing the website from http to https and from us ws to wss, everything was working fine, but after, it kept of saying "WebSocket connection to "wss://server" failed".

Client Side:

ws = new WebSocket('wss://ec2-3-97-91-10.ca-central-1.compute.amazonaws.com:443');

Server Side:

const express = require('express');
const https = require('https');
const WebSocket = require('ws');
const fs = require('fs');

var privateKey  = fs.readFileSync('SSL PRIVATE KEY.key', 'utf8');
var certificate = fs.readFileSync('SSL CERTIFICATE.crt', 'utf8');
var credentials = {key: privateKey, cert: certificate};



const port = 443;
var Application = express();
const server = https.createServer(credentials, Application);


var wss = new WebSocket.Server({ server })




wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(data) {
    wss.clients.forEach(function each(client) {
      if (client !== ws && client.readyState === WebSocket.OPEN) {
        client.send(data.toString());
      }
    })
  })
})

server.listen(port, function() {
  console.log(`Server is listening on ${port}!`)
})

The SSL certificate and private key are gotten from cloudflare.

If you want the full code, I uploaded it to a github repo here: https://github.com/stampixel/stampixel.ga

The domain im using is https://stampixel.ga

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!